package com.cw.jeeyt.service.converter.system;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.system.SystemCountryBo;
import com.cw.jeeyt.dao.model.system.SystemCountryDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 国家信息转换类
 *
 * @author chenw
 * @date 2019-03-10 13:04:25
 */
public class SystemCountryConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SystemCountryBo do2Bo(SystemCountryDo model) {
        if (model == null) {
            return null;
        }
        SystemCountryBo bo = new SystemCountryBo();
        bo.setId(model.getId());
        bo.setCountryCode(model.getCountryCode());
        bo.setCountryName(model.getCountryName());
        bo.setCountryEnName(model.getCountryEnName());
        bo.setComment(model.getComment());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SystemCountryDo bo2Do(SystemCountryBo bo) {
        if (bo == null) {
            return null;
        }
        SystemCountryDo model = new SystemCountryDo();
        model.setId(bo.getId());
        model.setCountryCode(bo.getCountryCode());
        model.setCountryName(bo.getCountryName());
        model.setCountryEnName(bo.getCountryEnName());
        model.setComment(bo.getComment());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<SystemCountryBo> doList2BoList(List<SystemCountryDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SystemCountryConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SystemCountryDo> boList2DoList(List<SystemCountryBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SystemCountryConverter::bo2Do));
    }
}